package com.geeksaga.dao.ibatis.mysql;


import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.geeksaga.dao.TablePartitionDao;
import com.geeksaga.dao.ibatis.BaseIBatisDao;
import com.geeksaga.domain.TablePartition;

/**
 * @author newbie
 * @since 0.1
 */
@Repository
public class TablePartitionDaoImpl extends BaseIBatisDao implements TablePartitionDao {

    /* (non-Javadoc)
     * @see com.geeksaga.dao.TablePartitionDao#add(com.geeksaga.domain.TablePartition)
     */
    public TablePartition add(TablePartition tablePartion) throws DataAccessException {
        return (TablePartition) getSqlMapClientTemplate().insert("TABLE_PARTITION.add", tablePartion);
    }
    
    /* (non-Javadoc)
     * @see com.geeksaga.dao.TablePartitionDao#find(com.geeksaga.domain.TablePartition)
     */
    public TablePartition find(TablePartition tablePartion) throws DataAccessException {
        return (TablePartition) getSqlMapClientTemplate().queryForObject("TABLE_PARTITION.find", tablePartion);
    }
    
    /* (non-Javadoc)
     * @see com.geeksaga.dao.TablePartitionDao#minusRowCount(com.geeksaga.domain.TablePartition)
     */
    public int minusRowCount(TablePartition tablePartion) throws DataAccessException {
        return getSqlMapClientTemplate().update("TABLE_PARTITION.minusRowCount", tablePartion);
    }

    /* (non-Javadoc)
     * @see com.geeksaga.dao.TablePartitionDao#plusRowCount(com.geeksaga.domain.TablePartition)
     */
    public int plusRowCount(TablePartition tablePartion) throws DataAccessException {
        return getSqlMapClientTemplate().update("TABLE_PARTITION.plusRowCount", tablePartion);
    }
}